package cn.itsource.basic.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data  /*lombok 自动提供getset方法toString*/
//@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult<T> {
    private Boolean success=true;//封装是否成功
    private String message="操作成功";//封装操作消息
    private T data;

    public AjaxResult() {
    }

    public AjaxResult(String message) {
        this.message = message;
    }

    public static AjaxResult me(){
        return new AjaxResult();
    }
    public static AjaxResult me(String message){

        return new AjaxResult(message);
    }
    public static AjaxResult setMsg(String message){//失败的
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success=false;
        ajaxResult.message = message;
        return ajaxResult;
    }

    public static AjaxResult setResult(Object obj){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.data = obj;
        return ajaxResult;
    }


    public static AjaxResult success(Object selectList) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.data = selectList;
        return ajaxResult;
    }

    public static AjaxResult success() {
        AjaxResult ajaxResult = new AjaxResult();
        return ajaxResult;
    }
}